#ifndef NETWORK_H
#define NETWORK_H

// RakNet includes
#include "RakPeerInterface.h"
#include "RakNetworkFactory.h"
#include "BitStream.h"
#include "RakSleep.h"

// My Includes
#include "Database.h"
#include "Enums.h"
#include "Character.h"

// Raknet namespaces
using namespace RakNet;

class Database;
class Character;

class Server
{
private:
	// Pointer to database object
	Database* dataBase;

	// Pointer to an array of pointers to character classes
	Character** characters;
public:
	// Pointer to RakPeer interface
	RakPeerInterface *peer;

	// Constructor
	Server();
	// Destructor
	~Server();

	// Set the pointer to the database object
	void setDataBase(Database* db);

	// Setup RakNet connection
	void Start(void);
	// Display number of connections
	unsigned ConnectionCount(void) const;
	// Process packets received
	void Update();

	// Querys the database to validate the user's account
	void loginChallenge(Packet *packet);
	// Relays the chat message
	void relayChatMsg(Packet *packet);

	// Add player
	void addPlayer(PlayerData playerData);
	// remove player
	void removePlayer(Packet *packet);
	// Handles network movement
	void networkMovement(Packet *packet);
	// Handles network rotation
	void networkRotation(Packet *packet);
};

#endif // NETWORK_H